﻿@using System
@using System.Linq
@using MZBlog.Core.Documents
@using MZBlog.Core.Extensions
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<MZBlog.Core.ViewProjections.Admin.BlogPostEditViewModel>
@{
    Layout = "_AdminLayout.cshtml";
}
<div class="row">
    <ol class="breadcrumb">
        <li><i class="fa fa-dashboard"></i> <a href="~/mz-admin">控制面板</a> </li>
        <li class="active"><i class="fa fa-edit"></i> 更新文章</li>
    </ol>
</div>

<div class="row">
        <form method="post" role="form" action="~/mz-admin/posts/edit/@Model.BlogPost.Id">
            <div class="form-group">
                <input id="post-title" type="text" class="form-control" name="Title" placeholder="标题" value="@Model.BlogPost.Title" required />
            </div>
            <div class="form-group">
                <input type="text" class="form-control" name="TitleSlug" placeholder="固定链接Key" value="@Model.BlogPost.TitleSlug" required />
            </div>
            <div class="form-group">
                <textarea id="post-content" data-provide="markdown" rows="30" name="MarkDown" placeholder="内容" required>@Model.BlogPost.MarkDown</textarea>
            </div>
            <div class="form-group">
                <input name="Tags" id="tags" class="form-control" value="@(Model.BlogPost.Tags==null?string.Empty:string.Join(",", Model.BlogPost.Tags.Select(s=>s.AsTag().Name)))" />
            </div>
            <div class="form-group">
                <label for="pubdate">发布时间(UTC):</label>
                <input id="pubdate" name="PubDate" value="@(Model.BlogPost.PubDate != DateTime.MinValue ? Model.BlogPost.PubDate : DateTime.UtcNow)" />
                &loz;
                <label for="published">发布</label>
                <input id="published" name="Published" value="true" type="checkbox" @(Model.BlogPost.PubDate <= DateTime.UtcNow && Model.BlogPost.Status == PublishStatus.Published ? "checked='checked'" : "") />
                <input type="submit" value="保存" class="btn btn-primary pull-right" />
            </div>
        </form>
</div>
@section PostScripts{
    <script src="~/scripts/jquery.tagsinput.js"></script>
    <script src="~/scripts/markdown.js"></script>
    <script>
        $('#tags').tagsInput({ 'width': '100%', 'defaultText': '添加标签' });
    </script>
}